home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™ 1987-1994 / MacHack™ '87 / Utilities ƒ / Text Editors ƒ / MEDIT ƒ / FORTRAN MACRO < prev    next >
Text File  |  1986-06-09  |  4KB  |  173 lines

  1. **************************************************************************
  2. * Fortran Macros Version 0.5                          June 5, 1986       *
  3. * by Gary White (CompuServe 74065,1636)   based on Pascal.mcr            *
  4. * example by Matthias Aebi                                               *
  5. **************************************************************************
  6. * Macros 1 and 2 should be run to initialize to your preferred values of
  7. * logical unit numbers for standard input and output, and to initialize
  8. * line numbers for Do loops and for Format statements.  Also, these 
  9. * macros work best with 'Auto Indent' turned OFF.
  10. * Comments welcome!
  11. * 1
  12. * Choose read and write logical unit numbers
  13. "LUN/U" {
  14.     SET(#0,10);
  15.     SET(#1,1000);
  16.     SET(#5,5);
  17.     prompt("READ UNIT#",#5);
  18.     Set($5,str(#5));
  19.     SET(#6,6);
  20.     prompt("WRITE UNIT#",#6);
  21.     Set($6,str(#6));
  22. };
  23. * 2
  24. * Specify line number label
  25. "Label/L" {
  26.     prompt("Start line numbers at ",#0);
  27.     Set($0,str(#0));
  28.     PROMPT("Start Format Line Numbers at ",#1);
  29.     SET($1,STR(#1));
  30. };
  31.  
  32. * 3
  33. * insert a line in the menu
  34. "-" {};
  35.  
  36. * 4
  37. * jumps to the next placeholder structure
  38. "Placeholder/-" {
  39.     Find("{.");
  40.     If L: = 0 And C: = 0 {
  41.         Find("{.");
  42.     };
  43.     Push;
  44.     Find(".}");
  45.     Select(L[,C[ | L:,C:)!;
  46.     Drop;
  47. };
  48.  
  49. * 5
  50. * insert a line in the menu
  51. "-" {};
  52. * 6
  53. * insert a DO template
  54. "Do/D" {
  55.     Push;
  56.     Insert("      DO ");
  57.     Insert($0);
  58.     Insert(" {.index.}={.start.},{.end.}\n");
  59.     Insert("      {.body.}\n");
  60.     Insert($0);
  61.     Insert("    CONTINUE\n");
  62.     Set(#0,#0+10);
  63.     Set($0,STR(#0));   
  64.     Call(17);
  65.  
  66. };
  67.  
  68. * 7
  69. * insert a SUBROUTINE template
  70. "Subroutine/S" {
  71.     Push;
  72.     Insert("      SUBROUTINE {.ProcName.} ({.Parameters.})\n");
  73.     Insert("      {.body.}\n");
  74.     Insert("      RETURN\n");
  75.     Insert("      END\n");
  76.     SET(#0,10);
  77.     SET(#1,1000);
  78.     SET($0,STR(#0));
  79.     SET($1,STR(#1));
  80.     Call(17);
  81. };
  82. * 8
  83. * insert a FUNCTION template
  84. "Function/F" {
  85.     Push;
  86.     Insert("      FUNCTION {.ProcName.} ({.Parameters.})\n");
  87.     Insert("      {.body.}\n");
  88.     Insert("      RETURN\n");
  89.     Insert("      END\n");
  90.     SET(#0,10);
  91.     SET(#1,1000);
  92.     SET($0,STR(#0));
  93.     SET($1,STR(#1));
  94.     Call(17);
  95. };
  96. * 9
  97. * READ statement
  98. "Read/R" {
  99.     Push;
  100.     Insert("      READ(");
  101.     Insert($5);
  102.     Insert(",");
  103.     Insert($1);
  104.     Insert(") {.list.}\n");   
  105.     Call(17);
  106. };
  107. * 10
  108. * Write statement
  109. "Write/W" {
  110.     Push;
  111.     Insert("      WRITE(");
  112.     Insert($6);
  113.     Insert(",");
  114.     Insert($1);
  115.     Insert(") {.list.}\n") ;  
  116.     Call(17);
  117. };
  118. * 11
  119. * insert an IF-THEN-ENDIF template
  120. "If/I" {
  121.     Push;
  122.     Insert("      IF ({.Condition.}) THEN\n      {.Statement.}\n");
  123.     Insert("      ENDIF\n");
  124.     Call(17);
  125. };
  126. * 12
  127. * insert an OPEN template
  128. "Open/P" {
  129. *  open (5,file='oburden.data',status='old')
  130.     Push;
  131.     Insert("      OPEN({.lun.},file={.file.},status={.status.})\n");
  132.     Call(17);
  133. };
  134. * 13
  135. * Insert CALL line
  136. "Call/A" {
  137.     Push;
  138.     Insert("      CALL {.subroutine.}({.arguments.})\n");
  139. };
  140. * 14
  141. * Insert FORMAT line
  142. "Format/M" {
  143.     Push;
  144.     Insert($1);
  145.     Insert("  FORMAT({.specifications.})\n");
  146.     Set(#1,#1+10);
  147.     Set($1,STR(#1));
  148.     CALL(17);
  149. };
  150.  
  151. * 15
  152. * Insert a comment line
  153. "Comment/K" {
  154.     Push;
  155.     Insert("C\n");
  156. };
  157. * 16
  158. * Insert a separator line
  159. "Border/B" {
  160.     Push;
  161.     Insert("C ------------------------------------------------------\n");
  162. };
  163.  
  164. * 17
  165. * select first placeholder
  166. {
  167.     Pop;
  168.     Find("{.");
  169.     Push;
  170.     Find(".}");
  171.     Select(L[,C[ | L:,C:)!;
  172.     Drop;
  173. }.